<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('用户余额变动详情')" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="role-form">
				    <input type="hidden" id="userId" name="userId" th:value="${userId}">
					<div class="select-list">
						<ul>
							<li class="select-time">
								<label>变动时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
	        
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-primary" onclick="$.table.exportExcel()" shiro:hasPermission="system:user:balanceExport">
					<i class="fa fa-download"></i> 导出
				</a>
		        <a class="btn btn-warning" onclick="closeItem()">
		            <i class="fa fa-reply-all"></i> 关闭
		        </a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		let prefix = ctx + "system/user";

		$(function() {
			let options = {
				url: prefix + "/balanceList",
				exportUrl: prefix + "/balanceExport",
				queryParams: queryParams,
				sortName: "createTime",
				sortOrder: "desc",
				modalName: "余额",
				columns: [{
					checkbox: true
				},
					{
						field: 'userId',
						title: '用户ID'
					},
					{
						field: 'befor',
						title: '变动前'
					},
					{
						field: 'after',
						title: '变动后'
					},
					{
						field: 'diff',
						title: '变动差值'
					},
					{
						field: 'reason',
						title: '变动原因'
					},
					{
						field: 'createBy',
						title: '操作人'
					},
					{
						field: 'createTime',
						title: '操作时间'
					}]
			};
			$.table.init(options);
		});
		
		function queryParams(params) {
			let search = $.table.queryParams(params);
			search.userId = $("#userId").val();
			return search;
		}
	</script>
</body>
</html>